<%@page import="java.util.List"%>
<%@page import="${entityPackage}.${model.upEntityFileName}"%>
<%@page import="cn.ysnk.clz.util.dateUtil.DateUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
${model.upEntityFileName} ${model.baseEntityName} = null;
String ${model.baseEntityName}Id = (String)request.getAttribute("${model.baseEntityName}Id");
if(${model.baseEntityName}Id!=null){
	${model.baseEntityName} = ${model.upEntityFileName}.dao.findById(${model.baseEntityName}Id);
}
%>
</head>
<body>
	<div class="container">
		<div class="page-header">
          <h2><%=${model.baseEntityName}==null?"新增${name}":"编辑${name}" %></h2>
          <p style="font-size:15px;"><font style="color:red;">*</font>为必填项</p>
        </div>
	   	<form class="form-horizontal" id="edit${model.upBaseEntityName}Form" method="post">
	   	<input type="hidden" name="${model.baseEntityName}Id" value="<%=${model.baseEntityName}Id==null?"":${model.baseEntityName}Id %>"/>
	   	<#list model.columns as column>
			<#if column.formField> 
			<div class="form-group">
			    <label for="${column.columnName}" class="col-sm-2 control-label">${column.commont}：<#if !column.nullAble><font style="color:red;">*</font></#if></label>
			    <div class="col-sm-8">
		    		<input style="display:none">
			      	<input autocomplete="off" universal-class="validate[<#if !column.nullAble>required,</#if>maxSize[75]${column.formValidator}]" type="<#if column.date>date<#else>text</#if>" class="form-control" value="<%=${model.baseEntityName}==null?"":${model.baseEntityName}.get${column.upcolumnName}() %>" id="${column.columnName}" name="${column.columnName}" placeholder="请填写${column.columnName}">
			    </div>
			  </div>
			</#if>
		</#list>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-8">
		      <button type="button" onclick="check${model.upBaseEntityName}Form()" class="btn btn-primary">保存</button>
		      <button type="button" onclick="${model.baseEntityName}back()" class="btn btn-default">返回</button>
		    </div>
		  </div>
		</form>
	</div>
	<script type="text/javascript">
			$(function(){
				var isCanSubmit = 1;
				jQuery("#edit${model.upBaseEntityName}Form").validationEngine(
				'attach',
				{
					promptPosition : "topLeft",
					onSuccess : function() {
						if (isCanSubmit == 1) {
							jQuery("#edit${model.upBaseEntityName}Form").submit();
							isCanSubmit++;
						}
				    }
			    });
			});
			function check${model.upBaseEntityName}Form(){
				if($("#edit${model.upBaseEntityName}Form").validationEngine("validate")){
					ajaxFormPost("${controllerUrl}/save${model.upBaseEntityName}","edit${model.upBaseEntityName}Form",function(){refreshTab('${controllerUrl}')},function(){refreshTab('${controllerUrl}')});
				}
			}
			function ${model.baseEntityName}back(){
				refreshTab('${controllerUrl}');
			}
		</script>
</body>

</html>